home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / ARCHIVERS / BEGINNER / TARZ / !tarZ / scannames < prev    next >
Text File  |  1999-04-24  |  1KB  |  62 lines

  1. BEGIN {
  2.       y = 1;
  3.       char x[ 128 ];
  4.       char z[ 128 ];
  5.       char n[ 128 ];
  6.       cmp=0;
  7.       }
  8.  
  9. /' /
  10.    {
  11. #
  12. # get around the '13'-character of linefeed from File
  13. #
  14.    if (y==1)
  15.       {
  16.       x=$1;
  17.       y=0;
  18.       }
  19.    else
  20.       x=substr($1,2);
  21. #
  22. # Change all !- Characters in _-characters in last part of name
  23. #
  24.    cmp=0;
  25.    i=split($2,s,".");
  26.    while (index(s[i],"!")!=0)
  27.       {
  28.       sub("!","_",s[i]);
  29.       cmp=1;
  30.       }
  31.    z=sprintf("%s%s",substr($2,1,length($2)-length(s[i])),s[i]);
  32. #
  33. # change last part of directoryname form "name" to "_name"
  34. #
  35.    if (x=="Directory")
  36.       {
  37.       if (cmp=0)
  38.          z=$2;
  39.       if (index(z,".")!=0)
  40.          {
  41.          i=split(z,s,".");
  42.          n=s[i];
  43.          }
  44.       else
  45.          n=z;
  46.       if (substr(s[i],1,1)!="_")
  47.          {
  48.          if (length(n)<10)
  49.             z=sprintf("%s_%s",substr(z,1,length(z)-length(n)),n);
  50.          else
  51.             z=sprintf("%s_%s",substr(z,1,length(z)-length(n)),substr(n,1,length(n)-1));
  52.          }
  53.       cmp=1;
  54.       }
  55. #
  56. # put changed name to a rename-command
  57. #
  58.    if (cmp== 1)
  59.       printf("rename %s %s\n",$2,z);
  60.    }
  61.  
  62. END {printf("*quit");}